//
//  XFDLoginAPI.m
//  BlocksKit
//
//  Created by 韩冰 on 2017/11/8.
//

#import "XFDLoginAPI.h"
#import "XFDRegisterController.h"
#import "XFDLogInController.h"
#import "XFDCommitSuccessController.h"
#import <XFDCommon/XFDUserManage.h>


@interface XFDLoginAPI()

@end


@implementation XFDLoginAPI
@synthesize registerCtr;
@synthesize logInCtr;
@synthesize commitCtr;
+ (instancetype)share{
    static dispatch_once_t onceToken;
    static XFDLoginAPI * api;
    dispatch_once(&onceToken, ^{
        api = [XFDLoginAPI new];
    });
    return api;
}


- (XFDRegisterController *)registerCtr{
    
    if (!registerCtr) {
       registerCtr = [[XFDRegisterController alloc] init];
    }
    return registerCtr;
}

- (XFDLogInController *)logInCtr{
    
    if (!logInCtr) {
        logInCtr = [[XFDLogInController alloc] init];
    }
    return logInCtr;
}
- (XFDCommitSuccessController *)commitCtr{
    if (!commitCtr) {
        commitCtr = [[XFDCommitSuccessController alloc] init];
    }
    return commitCtr;
    
}
- (void)logInwithClick:(BackBlock)backBlock{
    self.backBlockClick = ^{
        if (backBlock) {
            backBlock();
        }
    };
}
- (void)logIn{
    if (self.backBlockClick) {
        self.backBlockClick();
    }
}

- (NSString *)role{
    if ([XFDUserManage getUserType] == XFDUserTypeFlyer) {
        return @"FLYER";
    }else if ([XFDUserManage getUserType] == XFDUserTypeAdmin){
        return @"ADMIN";
    }
    return @"";
}
@end
